package leetcode_周赛._2021._202107._20210704;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/7/4 11:03
 * 统计好数字的数目
 * 算法：快速幂
 * 最后求出的幂结果就是当指数为奇数，底数的乘积
 */
public class _5802 {
    public static void main(String[] args) {
        System.out.println(new _5802().countGoodNumbers(4));
//        System.out.println(Math.log(4) / Math.log(2));
    }

    public int countGoodNumbers(long n) {
        long a = (long) Math.floor((n + 1) / 2);
        long b = (long) Math.floor(n / 2);
        long ans = 1;
        int mod = (int) (1e9 + 7);
        long tmp = 5;
        while (a > 0) {
            if ((a & 1) == 1) ans = ans * tmp % mod;
            a /= 2;
            tmp = tmp * tmp % mod;
        }
        tmp = 4;
        while (b > 0) {
            if (b % 2 == 0) {
                tmp = tmp * tmp % mod;
                b /= 2;
            } else {
                ans = ans * tmp % mod;
                tmp = tmp * tmp % mod;
                b = (b - 1) / 2;
            }
        }
        return (int) ans;
    }
    long count(long ans, long a, int b) {
        int mod = (int) (1e9 + 7);
        while (a > 0) {
            if (a % 2 == 0) {
                b = b * b % mod;
                a /= 2;
            } else {
                ans = ans * b % mod;
                b = b * b % mod;
                a = (a - 1) / 2;
            }
        }
        return ans;
    }

}
